package repository

import (
	"context"
	"user_service/domain"
	mlMongo "user_service/mongo"
)

type counterRepository struct {
	database   mlMongo.Database
	collection string
}

func NewCounterRepository(db mlMongo.Database) domain.CounterRepository {
	return &counterRepository{
		database:   db,
		collection: domain.CollectionCounter,
	}
}

func (cr *counterRepository) NextCounterValue(c context.Context, module string) (uint64, error) {
	collection := cr.database.Collection(cr.collection)
	value, err := collection.GetNextCounterValue(context.TODO(), module)
	if err != nil {
		return 0, err
	}
	return value, nil
}

func (cr *counterRepository) NextCounterValueS(c context.Context, module string) error {
	return nil
}
